<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Create a handle to used communicate with zookeeper</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="zookeeper.connect.html">« Zookeeper::connect</a></li>
      <li style="float: right;"><a href="zookeeper.create.html">Zookeeper::create »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.zookeeper.html">Zookeeper</a></li>
    <li>Create a handle to used communicate with zookeeper</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="zookeeper.construct" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">Zookeeper::__construct</h1>
  <p class="verinfo">(PECL zookeeper &gt;= 0.1.0)</p><p class="refpurpose"><span class="refname">Zookeeper::__construct</span> &mdash; <span class="dc-title">Create a handle to used communicate with zookeeper</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-zookeeper.construct-description">
  <h3 class="title">说明</h3>
  <div class="constructorsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="methodname"><strong>Zookeeper::__construct</strong></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$host</code><span class="initializer"> = &#039;&#039;</span></span>, <span class="methodparam"><span class="type"><a href="language.types.callable.html" class="type callable">callable</a></span> <code class="parameter">$watcher_cb</code><span class="initializer"> = <strong><code>null</code></strong></span></span>, <span class="methodparam"><span class="type">int</span> <code class="parameter">$recv_timeout</code><span class="initializer"> = 10000</span></span>)</div>

  <p class="para rdfs-comment">
   This method creates a new handle and a zookeeper session that corresponds to that handle. Session establishment is asynchronous, meaning that the session should not be considered established until (and unless) an event of state ZOO_CONNECTED_STATE is received.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-zookeeper.construct-parameters">
  <h3 class="title">参数</h3>
  <dl>
   
    <dt>
<code class="parameter">host</code></dt>

    <dd>

     <p class="para">
      comma separated host:port pairs, each corresponding to a zk server. e.g. &quot;127.0.0.1:3000,127.0.0.1:3001,127.0.0.1:3002&quot;
     </p>
    </dd>

   
   
    <dt>
<code class="parameter">watcher_cb</code></dt>

    <dd>

     <p class="para">
      the global watcher callback function. When notifications are triggered this function will be invoked.
     </p>
    </dd>

   
   
    <dt>
<code class="parameter">recv_timeout</code></dt>

    <dd>

     <p class="para">
      the timeout for this session, only valid if the connections is currently connected (ie. last watcher state is ZOO_CONNECTED_STATE).
     </p>
    </dd>

   
  </dl>

 </div>


 <div class="refsect1 errors" id="refsect1-zookeeper.construct-errors">
  <h3 class="title">错误／异常</h3>
  <p class="para">
   This method emits PHP error/warning when parameters count or types are wrong or could not init instance.
  </p>
  <div class="caution"><strong class="caution">警告</strong>
    <p class="para">
      Since version 0.3.0, this method emits <span class="classname"><a href="class.zookeeperexception.html" class="classname">ZookeeperException</a></span> and it&#039;s derivatives.
    </p>
  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-zookeeper.construct-seealso">
  <h3 class="title">参见</h3>
  <ul class="simplelist">
   <li class="member"><span class="methodname"><a href="zookeeper.connect.html" class="methodname" rel="rdfs-seeAlso">Zookeeper::connect()</a> - Create a handle to used communicate with zookeeper</span></li>
   <li class="member"><span class="classname"><a href="class.zookeeperexception.html" class="classname">ZookeeperException</a></span></li>
  </ul>
 </div>


</div></div></div></body></html>